class Solution:
    def findMin(self, nums: list) -> int:
        max_i = len(nums) - 1
        if max_i < 30:
            return min(nums)
        min_i, i = 0, max_i // 2
        while nums[i] > nums[i-1]:
            if nums[i] < nums[-1]:
                max_i, i = i, (i + min_i) // 2
            else:
                min_i, i = i, (i + max_i) // 2
        return nums[i]


a = Solution()
print(a.findMin([3, 4, 5, 1, 2]))
print(a.findMin([4, 5, 6, 7, 0, 1, 2]))

